package com.sikaryofficial.system;

import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;

/**
 * @author : wuweihong
 * @desc : TODO  请填写你的功能描述
 * @date : 2025-08-11
 */


public class JasyptUtil {

	public static String decrypt(String password, String encryptedText) {
		PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
		encryptor.setPoolSize(1);
		SimpleStringPBEConfig config = new SimpleStringPBEConfig();
		config.setPassword(password);
		config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");
		config.setAlgorithm("PBEWithMD5AndDES");
		encryptor.setConfig(config);
		return encryptor.decrypt(encryptedText);
	}

	public static String encrypt(String password,  String encryptedText) {
		PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
		encryptor.setPoolSize(1);
		SimpleStringPBEConfig config = new SimpleStringPBEConfig();
		config.setPassword(password);
		config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");
		config.setAlgorithm("PBEWithMD5AndDES");
		encryptor.setConfig(config);
		return encryptor.encrypt(encryptedText);
	}

	public static void main(String[] args) {
		String appId = "Ske20231023@";
//		String data = encrypt("DIGLoserSKE2025", appId);
		String source = decrypt("J8YLoserSKE2024", "gkW5czFR0z1Qc/QW0YRGYKkLyPJxF82W" );
		System.out.println(source);
	}

}
